<?php

    class Related_Pages extends ActiveRecord {
        
        function _setup()
        {
            $this->table = DB_PREFIX.'related_pages';
        }
        
        function save_related($page_id,$pages)
        {
            if (is_array($pages) && !empty($pages)) {
                $this->db->Execute('delete from related_pages where page_id=?',$page_id);
                $stmt = $this->db->Prepare('insert into related_pages (page_id,related_page_id) values (?,?)');
                foreach ($pages as $page) 
                {
                    $this->db->Execute($stmt, array($page_id,$page));
                }
            }
        }
    }

?>